<template xmlns="http://www.w3.org/1999/html">
  <div id="system" class="warp system">
    <postHead active="wode" :showAction="true"></postHead>

    <div class="container">
      <div class="main-left">
        <div class="system-lt">
          <ul class="sidemenu">
            <li class="active">
              <a><span class="iconmd iconmd-files"></span>基本信息</a>
            </li>
            <li @click="toCountManage">
              <a><span class="iconmd iconmd-user"></span>账号管理</a>
            </li>
            <li @click="toChildManage">
              <a><span class="iconmd iconmd-adduser"></span>子账号管理</a>
            </li>
          </ul>
        </div>
        <!-- /.system-lt -->
      </div>
      <!-- /.main-left -->
      <!-- left /end -->

      <div class="main-right">
        <div class="system-rt">
          <!-- /.resumeimport-tab -->

          <!-- 中文信息 -->
          <div class="company">
            <div class="company-info1">
              <div class="table_head">
                <div class="tofu-title systitle">基本信息</div>
                <div class="addressnew newchildcompany" @click="saveComapny"
                     v-if="$root.userInfo.user.role == 'admin'">
                  <a class="btn btn-primary">保存信息</a>
                </div>
              </div>

              <div class="form-horizontal">
                <div id="baseinfo">
                  <div class="form-group">
                    <label class="register-form-label control-label">
                      <span class="required">*</span>公司名称</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control" v-model="form.name" disabled
                             id="companyname"/>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label">
                      <span class="required"></span>公司简称</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control" v-model="form.abbreviation"
                             id="companyname"/>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="register-form-label control-label"><span class="required"></span>
                      LOGO</label>
                    <div class="register-form-control">
                      <a class="BusinessLicense" v-if="form.logo">
                        <img :src="form.logoUrl" style="height: 80px; width: 80px"/>
                        <span @click="deleteImgLogo(null)">删除</span></a>

                      <div class="upload_div">
                        <i class="el-icon-plus"></i>
                        <input type="file" accept="image/*"
                               @change="changeFileLogo(null, $event)"/>
                      </div>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label">
                      <span class="required">*</span>上传营业执照
                    </label>
                    <div class="register-form-control">
                      <a class="BusinessLicense" v-if="form.licenceImg">
                        <img :src="form.licenceImgUrl" style="height: 80px; width: 80px"/>
                        <span @click="deleteImg">删除</span></a>

                      <div class="upload_div">
                        <i class="el-icon-plus"></i>
                        <input type="file" accept="image/*" @change="changeFile()"/>
                      </div>
                    </div>
                  </div>

                  <div class="form-group" style="width: 100% !important; clear: both">
                    <label class="register-form-label control-label" style="width: 16.5% !important"><span class="required"></span>
                      轮播图</label>
                    <div class="register-form-control">
                      <template v-for="(item,index) in bannerImagePaths">
                        <a class="BusinessLicense">
                          <img :src="item.url" style="height: 80px; width: 80px"/>
                          <span @click="deleteImgList(index)">删除</span></a>
                      </template>

                      <div class="upload_div">
                        <i class="el-icon-plus"></i>
                        <input type="file" accept="image/*" @change="changeFileList(null, $event)"/>
                      </div>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="register-form-label control-label"><span
                        class="required">*</span>统一社会信用代码</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control" v-model="form.creditCode"
                             id="businesslicensecode"/>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="register-form-label control-label"><span class="required"></span>
                      企业官网</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control" v-model="form.officialWebsite"
                             id="businesslicensecode"/>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label"><span class="required"></span>
                      企业性质</label>
                    <div class="register-form-control">
                      <el-select v-model="form.enterpriseNature" placeholder="请选择"
                                 style="width:100%">
                        <el-option v-for="item in dictInfo.enterpriseNature" :key="item.value"
                                   :label="item.label" :value="item.value">
                        </el-option>
                      </el-select>
                      <!-- <select id="OwnershipType" multiple class="form-control OwnershipType"
                        v-model="form.enterpriseNature">
                        <template v-for="item in dictInfo.enterpriseNature">
                          <option :value="item.value">{{ item.label }}</option>
                        </template>
</select> -->
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label"><span class="required"></span>
                      微信公众号</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control" v-model="form.wechatOfficialAccount"
                             id="businesslicensecode"/>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label"><span class="required"></span>
                      企业规模</label>
                    <div class="register-form-control">
                      <el-select v-model="form.enterpriseScale" multiple placeholder="请选择"
                                 style="width:100%">
                        <el-option v-for="item in dictInfo.enterpriseScale" :key="item.value"
                                   :label="item.label" :value="item.value">
                        </el-option>
                      </el-select>
                      <!-- <select id="OwnershipType" class="form-control OwnershipType"
                        v-model="form.enterpriseScale">
                        <template v-for="item in dictInfo.enterpriseScale">
                          <option :value="item.value">{{ item.label }}</option>
                        </template>
                      </select> -->
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label"><span
                        class="required">*</span>联系人</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control" v-model="form.contactName"
                             id="businesslicensecode"/>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label"><span class="required"></span>
                      营收产能</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control"/>
                    </div>
                  </div>


                  <div class="form-group">
                    <label class="register-form-label control-label"><span
                        class="required">*</span>联系人手机</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control" v-model="form.contactPhone"
                             id="businesslicensecode"/>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="register-form-label control-label"><span class="required"></span>
                      员工人数</label>
                    <div class="register-form-control">
                      <input type="number" class="form-control" v-model="form.staffsNum"
                             id="businesslicensecode"/>

                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label"><span
                        class="required"></span>座机号码</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control" v-model="form.landlineNumber"
                             id="businesslicensecode"/>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label"><span class="required"></span>
                      上市类型</label>
                    <div class="register-form-control">
                      <el-select v-model="form.listingType" multiple placeholder="请选择"
                                 style="width:100%">
                        <el-option v-for="item in dictInfo.listingType" :key="item.value"
                                   :label="item.label" :value="item.value">
                        </el-option>
                      </el-select>
                      <!-- <select id="OwnershipType" class="form-control OwnershipType"
                        v-model="form.listingType">
                        <template v-for="item in dictInfo.listingType">
                          <option :value="item.value">{{ item.label }}</option>
                        </template>
                      </select> -->
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="register-form-label control-label"><span
                        class="required"></span>邮箱</label>
                    <div class="register-form-control">
                      <input type="text" class="form-control" v-model="form.email"
                             id="businesslicensecode"/>
                    </div>
                  </div>



                  <div class="form-group">
                    <label class="register-form-label control-label"><span class="required"></span>
                      企业行业</label>
                    <div class="register-form-control">
                      <div class="select_input"
                           @click="showSelectEnterpriseIndustry(form, 'enterpriseIndustry', 'enterpriseIndustryName')">
                        <span>{{ form.enterpriseIndustryName }}</span>
                      </div>

                      <!-- <el-cascader v-model="form.enterpriseIndustry" :options="enterpriseIndustry"
                        placeholder="请选择或搜索所属行业" filterable clearable style="width: 100%"
                        :props="props">
                      </el-cascader> -->
                    </div>
                  </div>



                  <div class="form-group" style="width: 100% !important; clear: both">
                    <label class="register-form-label control-label" style="width: 16.5%">
                      <span class="required"></span>
                      企业介绍</label>
                    <div class="register-form-control" style="width: 80%;display: inline-block;">
                      <!-- <textarea style="width: 100%" v-model="form.introduction"
                        placeholder="请输入企业介绍" rows="10"></textarea> -->
                      <Toolbar :editor="editorNextThree"
                               :defaultConfig="toolbarConfig" :mode="mode"/>
                      <Editor style="height: 200px; overflow-y: hidden;border: 1px solid #ccc"
                              v-model="form.introduction" @onCreated="onCreatedNextThree"
                              :defaultConfig="editorConfig" :mode="mode"/>

                    </div>
                  </div>
                </div>
              </div>
            </div>

            <div class="company-info1">
              <div class="table_head">
                <div class="tofu-title systitle">子公司设置</div>
                <div class="addressnew newchildcompany" @click="addChild">
                  <a class="btn btn-primary">新增子公司</a>
                </div>
              </div>


              <el-table :data="childList" ref="multipleTable" stripe border style="width: 100%">

                <el-table-column label="公司名称" prop="name">


                </el-table-column>
                <el-table-column label="公司简称" prop="abbreviation">

                </el-table-column>
                <el-table-column label="企业行业" prop="enterpriseIndustryStr">

                </el-table-column>
                <el-table-column label="企业规模">
                  <template slot-scope="scope">
                    <span>{{ scope.row.enterpriseScaleStr }}</span>
                  </template>
                </el-table-column>

                <el-table-column label="年度营收">
                  <template slot-scope="scope">
                    <span v-if="scope.row.annualRevenue">{{ scope.row.annualRevenue }}万元</span>
                  </template>
                </el-table-column>
                <el-table-column label="上市类型">
                  <template slot-scope="scope">
                    <span>{{ scope.row.listingTypeStr }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="企业性质">
                  <template slot-scope="scope">
										<span>{{
                        getPostInfoMain(scope.row.enterpriseNature, 'enterpriseNature')
                      }}</span>
                  </template>
                </el-table-column>

                <el-table-column label="员工人数" prop="staffsNum">

                </el-table-column>

                <el-table-column label="操作" v-if="$root.userInfo.user.role == 'admin'">
                  <template slot-scope="scope">
                    <el-button type="text" @click="editChild(scope.row)">编辑</el-button>
                    <el-button type="text" @click="deleteChildComapny(scope.row)">删除</el-button>
                  </template>
                </el-table-column>


              </el-table>
            </div>
          </div>

        </div>

      </div>

    </div>


    <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" width="870px">
      <el-form :model="form" style="display:inline-block">
        <el-form-item label="公司名称" :label-width="formLabelWidth" style="width:50%;float:left">
          <el-input v-model="childForm.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="公司简称" :label-width="formLabelWidth" style="width:50%;float:left">
          <el-input v-model="childForm.abbreviation" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="企业行业" :label-width="formLabelWidth" style="width:100%;float:left;max-width:830px">
          <!-- <el-cascader v-model="childForm.enterpriseIndustry"
              :options="enterpriseIndustry" placeholder="请选择或搜索所属行业" filterable  :collapse-tags="true"
              clearable :props="props" style="width:275px">
            </el-cascader> -->
          <div class="select_input"
               @click="showSelectEnterpriseIndustry(childForm, 'enterpriseIndustry', 'enterpriseIndustryName')">
            <span>{{ childForm.enterpriseIndustryName }}</span>
          </div>


        </el-form-item>

        <el-form-item label="企业规模" :label-width="formLabelWidth" style="width:50%;float:left">
          <el-select v-model="childForm.enterpriseScale" multiple placeholder="请选择企业规模" style="width:275px">
            <template v-for="json in dictInfo.enterpriseScale">
              <el-option :label="json.label" :value="json.value"></el-option>

            </template>


          </el-select>
        </el-form-item>

        <el-form-item label="年度营收" :label-width="formLabelWidth" style="width:50%;float:left">
          <el-input v-model="childForm.annualRevenue" autocomplete="off" style="width:120px"></el-input>
          <span style="margin-left:5px">万元</span>
          <span v-if="childForm.annualRevenue >= 10000" style="margin-left:5px;color:red">({{
              childForm.annualRevenue
              / 10000
            }}亿)</span>
        </el-form-item>

        <el-form-item label="企业性质" :label-width="formLabelWidth" style="width:50%;float:left">
          <el-select v-model="childForm.enterpriseNature" placeholder="请选择企业性质" style="width:275px">
            <template v-for="json in dictInfo.enterpriseNature">
              <el-option :label="json.label" :value="json.value"></el-option>

            </template>


          </el-select>
        </el-form-item>
        <el-form-item label="员工人数" :label-width="formLabelWidth" style="width:50%;float:left">
          <el-input v-model="childForm.staffsNum" autocomplete="off"></el-input>
        </el-form-item>


        <el-form-item label="上市类型" :label-width="formLabelWidth" style="width:50%;float:left">
          <el-select v-model="childForm.listingType" multiple placeholder="请选择上市类型" style="width:275px">
            <template v-for="json in dictInfo.listingType">
              <el-option :label="json.label" :value="json.value"></el-option>
            </template>
          </el-select>
        </el-form-item>


        <el-form-item label="企业官网" :label-width="formLabelWidth" style="width:50%;float:left">
          <el-input v-model="childForm.officialWebsite" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="微信公众号" :label-width="formLabelWidth" style="width:50%;float:left">
          <el-input v-model="childForm.wechatOfficialAccount" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="企业介绍" :label-width="formLabelWidth" style="width:100%;float:left">


          <Toolbar :editor="editorSecond"
                   :defaultConfig="toolbarConfig" :mode="mode"/>
          <Editor style="height: 200px; overflow-y: hidden;border: 1px solid #ccc"
                  v-model="childForm.introduction" @onCreated="onCreatedSecond"
                  :defaultConfig="editorConfig" :mode="mode"/>

        </el-form-item>


      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="saveChildCompany">确 定</el-button>
      </div>
    </el-dialog>

    <enterprise-industry @closeSelect="closeSelect" :haveSelect="haveSelect" v-if="showSelectIndustry"
                         @saveData="saveData" :title="'选择行业'"
                         :selectArry="enterpriseIndustry"></enterprise-industry>

  </div>
</template>
<script>
import {Editor, Toolbar} from "@wangeditor/editor-for-vue";
import postHead from "@/components/postHead.vue";
import homeapi from "@/api/api.js";
import until from "@/api/until";
import enterpriseIndustry from '@/components/enterPriseindustry.vue'


export default {
  name: "login",
  data() {
    return {
      phone: "",
      haveCheck: false,
      code: "",
      title: "",
      loginType: 1,
      loginCode: 1,
      active: 2,
      form: {
        name: "",
        logo: "",
        logoUrl: "",
        licenceImgUrl: "",
        nickName: "",
        annualRevenue: "",
        balance: "",
        contactName: "",
        bannerImagePaths: '',
        contactPhone: "",
        creditCode: "",
        email: "",
        enterpriseIndustry: "",
        enterpriseNature: "",
        enterpriseScale: "",
        id: "",
        img: "",
        introduction: "",
        landlineNumber: "",
        licenceImg: "",
        listingType: "",
        officialWebsite: "",
        phone: "",
        staffsNum: "",
        title: "",
        wechatOfficialAccount: "",
        abbreviation: "",
      },
      bannerImagePaths: [],
      mode: "default", // 'default' or 'simple'
      toolbarConfig: {
        toolbarKeys: [
          //自定义菜单选项

          "fontSize",
          "bold",

          "color",
          "bgColor",
          "justifyLeft",
          "justifyRight",
          "justifyCenter",
          "justifyJustify",
        ],
        excludeKeys: ["sub", "sup"],
      },
      editorSecond: null,
      editorConfig: {},

      userForm: {
        inviteCode: "",
        inviter: "",
        inviterPhone: "",
        name: "",
        nickName: "",
        workplace: "",
        idCard: "",
        personHighestDegree: {},
        personImportantUnits: {},
      },
      enterpriseScaleList: [],
      enterpriseIndustry: [],
      enterpriseNatureList: [],
      staffsNumList: [],
      editorNextThree: null,

      cateProps: {
        value: "value",
        label: "label",
        children: "children",
      },
      props: {
        value: "id",
        label: "text",
        children: "children",
        multiple: true,

      },
      showCode: true,
      time: 60,
      dictInfo: {},

      childList: [],


      nowItem: {},
      nowType: "",
      nowName: "",
      haveSelect: [],
      showSelectIndustry: false,


      dialogTitle: '新增子公司',
      dialogFormVisible: false,
      formLabelWidth: "140px",
      childForm: {
        name: "",
        abbreviation: "",
        annualRevenue: "",
        enterpriseIndustry: [],
        enterpriseNature: "",
        enterpriseScale: "",
        id: "",
        introduction: "",
        listingType: '',
        officialWebsite: "",
        staffsNum: "",
      }
    };
  },
  components: {
    postHead, enterpriseIndustry, Editor, Toolbar
  },
  mounted() {
    this.getDictList();
    this.getIndustryList();
    this.getCompanyInfo();
    this.getChildCompanyList();
  },
  methods: {
    onCreatedNextThree(editor) {
      this.editorNextThree = Object.seal(editor); // 一定要用 Object.seal() ，否则会报错
    },
    onCreatedSecond(editor) {
      this.editorSecond = Object.seal(editor);
    },
    showSelectEnterpriseIndustry(nowItem, nowType, nowName) {
      this.nowItem = nowItem
      this.nowType = nowType
      this.nowName = nowName

      this.haveSelect = nowItem[nowType]

      this.showSelectIndustry = true
    },
    closeSelect() {
      this.showSelectIndustry = false;
    },
    saveData(item) {
      this.nowItem[this.nowType] = item.arryList
      this.nowItem[this.nowName] = item.arryName
      this.closeSelect();
      this.closeSelectAffiliation();
    },
    toCountManage() {
      this.$router.push("/company/accountInfo");
    },
    getPostInfoMain(value, type) {
      let name = ""
      console.log(type)
      if (this.dictInfo[type]) {
        this.dictInfo[type].map(res => {
          if (res.value == value) {
            name = res.label
          }
        })
      }

      return name
    },

    //获取子公司信息
    async getChildCompanyList() {
      this.companyList = [];
      let data = await homeapi.getChildCompanyList();
      if (data.code == 200) {
        if (data.result.length > 0) {
          data.result.map((res) => {
            res.logoUrl =
                "https://www.aizhaopin.pro/prod-api/sys/common/static/" +
                res.logo;
          });
          this.childList = data.result;
        }
      }
    },

    toChildManage() {
      this.$router.push("/company/childAccount");
    },

    //获取公司信息
    async getCompanyInfo() {
      let data = await homeapi.getCompanyInfo();
      if (data.code == 200) {
        this.companyInfo = data.result;
        this.form = data.result;
        this.form.logoUrl =
            "https://www.aizhaopin.pro/prod-api/sys/common/static/" +
            this.form.logo;
        this.form.licenceImgUrl =
            "https://www.aizhaopin.pro/prod-api/sys/common/static/" +
            this.form.licenceImg;

        if (this.form.bannerImagePaths) {
          let imgList = this.form.bannerImagePaths.split(",")
          imgList.map(res => {
            let jsonData = {};
            jsonData.url = "https://www.aizhaopin.pro/prod-api/sys/common/static/" + res;
            jsonData.path = res;
            this.bannerImagePaths.push(jsonData)
          })
        }

      }
    },
    //保存公司信息
    async saveComapny() {
      let form = this.form;
      form.bannerImagePaths = ""
      this.bannerImagePaths.map(res => {
        if (form.bannerImagePaths == "") {
          form.bannerImagePaths = res.path;
        } else {
          form.bannerImagePaths += "," + res.path;
        }
      })
      let data = await homeapi.editCompanyInfo(form);
      if (data.code == 200) {
        this.$message.success("保存成功");
        this.getCompanyInfo();

      }


    },
    editChild(form) {
      this.childForm = form;
      this.dialogFormVisible = true;
      this.dialogTitle = "编辑子公司"
    },

    //编辑子公司信息
    async editChildCompany(parm) {
      let data = await homeapi.editChildCompany(parm);
      if (data.code == 200) {
        this.dialogFormVisible = false;
        this.getChildCompanyList();
      }
    },

    //保存子公司信息
    async saveChildCompany() {
      let form = this.childForm
      if (form.id) {
        this.editChildCompany(form)
      } else {
        let data = await homeapi.addchildcompany(form);
        if (data.code == 200) {
          this.dialogFormVisible = false;
          this.getChildCompanyList();
        }
      }


    },

    addChild() {
      this.childForm = {
        name: "",
        abbreviation: "",
        annualRevenue: "",
        enterpriseIndustry: [],
        enterpriseNature: "",
        enterpriseScale: "",
        id: "",
        introduction: "",
        listingType: '',
        officialWebsite: "",
        staffsNum: "",
      }
      this.dialogFormVisible = true
    },

    toLogin() {
      this.$router.push("/login/loginnew");
    },
    setActive(type) {
      this.active = type;
    },
    //获取数据字典
    async getDictList() {
      let data = await homeapi.getDictList();
      if (data.code == 200) {
        this.dictInfo = data.result;
      }
    },
    deleteImg() {
      this.form.licenceImg = "";
      this.form.licenceImgUrl = "";
    },

    //获取行业列表
    async getIndustryList() {
      let data = await homeapi.getIndustryList();
      if (data.code == 200) {
        data.result.map((res) => {
          res.text = res.name;
          if (res.child.length > 0) {
            res.child.map((json) => {
              json.text = json.name;
            });
            res.children = res.child;
            res.children.map((json) => {
              if (json.child.length > 0) {
                json.child.map((item) => {
                  item.text = item.name;
                });
                json.children = json.child;
              }
            });
          }
        });

        this.enterpriseIndustry = data.result;
      }
    },

    async sendCode() {
      let phone = this.phone;
      if (phone.length != 11) {
        this.$message.error("请传入正确的手机号");
        return false;
      }

      let data = await homeapi.sendCode({phone});

      if (data.code == 200) {
        this.showCode = false;
        this.getTimeNext();
      } else {
        this.$message.error(data.message);
      }
    },

    getTimeNext() {
      if (this.time > 0) {
        this.time = this.time - 1;
        setTimeout(() => {
          this.getTimeNext();
        }, 1000);
      } else {
        this.showCode = true;
        this.time = 60;
      }
    },
    setCheck() {
      this.haveCheck = true;
    },
    async toRegister() {
      if (this.active == 2) {
        let code = this.code;
        let phone = this.phone;

        let type = this.active;
        let form = this.userForm;
        form.code = code;
        form.phone = phone;
        this.loading = true;
        let data = await homeapi.registerUser(form);
        if (data.code == 200) {
          this.$message.success("注册成功");
          until.setCookie("token", data.result);
          this.$router.push("/user");
        } else {
          this.loading = false;
          this.$message.error(data.message);
        }
      } else {
        let code = this.code;
        let phone = this.phone;
        let type = this.active;
        let form = this.form;
        form.code = code;
        form.phone = phone;
        this.loading = true;
        let data = await homeapi.registerCompany(form);
        if (data.code == 200) {
          this.$message.success("注册成功");
          until.setCookie("token", data.result);
          this.$router.push("/");
        } else {
          this.loading = false;
          this.$message.error(data.message);
        }
      }
    },
    async getUserInfo() {
      let data = await homeapi.getUserinfo();
      if (data.code == 402) {
      }
      if (data.code == 403) {
        this.$router.push("/company");
      }
      if (data.code == 200) {
      }
    },

    async sureEdit() {
      if (this.active == 1) {
        let form = this.form;

        let data = await homeapi.editCompany(form);
        if (data.code == 200) {
          this.loading = false;
          this.$message.success("注册成功");
          this.$router.push("/");
        }
      } else {
        let form = this.form;

        let data = await homeapi.editUser(form);
        if (data.code == 200) {
          this.loading = false;
          this.$message.success("注册成功");
          this.$router.push("/");
        }
      }
    },
    async changeFileLogo(item, e) {

      if (e.target.files.length > 0) {
        let file = e.target.files[0];
        var formData = new FormData();
        // 服务端要求参数是 pic1
        formData.append("file", file);
        let data = await homeapi.uploadFile(formData);
        if (data.code == 200) {
          if (item) {
            item.logoUrl = data.result.url;
            item.logo = data.result.path;
          } else {
            this.form.logoUrl = data.result.url;
            this.form.logo = data.result.path;
          }
        }
      }
    },


    deleteChildComapny(item) {
      this.$confirm("此操作将删除该子公司, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
          .then(async () => {
            let id = item.id;
            const data = await homeapi.deleteChildCompany({id});
            if (data.code == 200) {
              this.getChildCompanyList();
            }
          })
          .catch(() => {
          });
    },
    deleteImgLogo(item) {
      console.log(item)
      if (item) {
        item.logo = "";
        item.logoUrl = "";
      } else {
        this.form.logo = "";
        this.form.logoUrl = "";
      }
    },
    async changeFile(item, e) {
      if (e.target.files.length > 0) {
        let file = e.target.files[0];
        var formData = new FormData();
        // 服务端要求参数是 pic1
        formData.append("file", file);
        let data = await homeapi.uploadFile(formData);
        if (data.code == 200) {
          this.form.licenceImgUrl = data.result.url;
          this.form.licenceImg = data.result.path;
        }
      }
    },


    async changeFileList(item, e) {

      if (e.target.files.length > 0) {
        let file = e.target.files[0];
        var formData = new FormData();
        // 服务端要求参数是 pic1
        formData.append("file", file);
        let data = await homeapi.uploadFile(formData);
        if (data.code == 200) {
          this.bannerImagePaths.push(data.result)


        }
      }
    },

    deleteImgList(index) {
      this.bannerImagePaths.splice(index)
    },

  },
};
</script>
<style src="@wangeditor/editor/dist/css/style.css"></style>
<style scoped lang="less">

@import "@/assets/lpyp.min.css";

.footer {
  position: fixed;
}

.sidemenu li {
  font-size: 16px;
}

.container {
  width: 100%;
  height: calc(100vh - 125px);
  overflow: auto;
  margin-top: 15px;
}

.main-left {
  position: fixed;
  top: 95px;
  bottom: 30px;
  background: #fff;
}

.system-lt {
  border: 0px;
}

.system-rt {
  border: 0px;
}

.main-right {
  margin-left: 0px;
}

.navbar-header {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.navbar-header span {
  font-size: 24px;
  color: #fc7b24;
  font-weight: bold;
}

.upload_div {
  width: 80px;
  height: 80px;
  border: 1px solid #e6e6e6;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

.upload_div input {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  cursor: pointer;
}

.upload_div i {
  font-size: 18px;
}

.register-form-control {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.form-group textarea {
  padding: 15px;
  box-sizing: border-box;
  border: 1px solid #ccc;
  outline: none;
}

#jayaddnewchildcompany {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.company-form-lump {
  display: inline-block;
}

.form-control {
  height: 40px;
}
</style>
<style>
.el-table th.el-table__cell {
  background: #ebebeb;
}

.el-table thead {
  color: #333333;
  font-weight: bold;
}

.el-table--border .el-table__cell,
.el-table__body-wrapper .el-table--border.is-scrolling-left ~ .el-table__fixed {
  border-right: 1px solid #ddd;
}

.el-table .el-table__cell {
  padding: 8px !important;
}

.el-table__row .el-table__cell {
  padding: 10px 0 !important;
}

.table_head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #ddd;
  margin-bottom: 20px;
  padding-bottom: 15px;
}

.systitle::after {
  display: none;
  margin-bottom: 0px !important;
}

.systitle {
  margin-bottom: 0px !important;
}

.BusinessLicense {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  margin-right: 10px;
  margin-top: 20px;
}
</style>
